package com.formiaomiao.demain.controller;

import com.corundumstudio.socketio.SocketIOClient;
import com.formiaomiao.demain.socket.MessageEventHandler;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class SocketController {

    @ResponseBody
    @GetMapping(value = "/socket")
    private Object Opinion(@RequestParam(name = "mac", required = false) String mac){
        SocketIOClient client = MessageEventHandler.webSocketMap.get(mac);
//        DomainResponse msg = new DomainResponse(Integer.parseInt(mac),mac,"指定给"+mac+"用户发消息");
        client.sendEvent("messageevent","haha======++");
        return "连接成功";
    }

}
